<template>
  <div class="login" v-show="visible">
    <div class="login-wrap">
      <div class="top">
        <span>手机号登陆</span>
        <i @click="btnClose">x</i>
      </div>
      <form class="login-form">
        <div>
          <select name="country" id="+86" class="country">
            <option value="1">中国 +86</option>
            <option value="2">香港 +852</option>
            <option value="3">澳门 +853</option>
            <option value="4">台湾 +886</option>
          </select>
          <input type="text" v-model="num" class="num" />
        </div>
        <input type="text" v-model="pwd" class="pwd" />
        <div class="msg">
          <a href="javascript:;">短信登陆</a>
          <div class="doLogin">
            <input type="checkbox" name="msg" />
            <label for="msg">自动登录</label>
          </div>
        </div>
        <button @click.prevent="toLogin">登陆</button>
      </form>
    </div>
  </div>
</template>

<script>
import { reqToLogin } from '@/api/rankList'
import { mapActions, mapState } from 'vuex'
export default {
  name: 'Login',
  props: ['visible', 'isShow'],
  data() {
    return {
      num: '15610382823',
      pwd: 'titanic333',
    }
  },
  methods: {
    ...mapActions('ranklist', ['toSaveToken']),
    toLogin() {
      // await reqToLogin(this.num, this.pwd)
      this.toSaveToken([this.num, this.pwd])
      // console.log(this.checkRight)
      this.$emit('update:isShow', true)
      this.$emit('update:visible', false)
    },
    btnClose() {
      this.$emit('update:visible', false)
    },
  },
  computed: {
    ...mapState('ranklist', ['checkRight']),
  },
}
</script>

<style lang="less" scoped>
.login {
  position: fixed;
  z-index: 999;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.3);
  .login-wrap {
    width: 528px;
    height: 274px;
    background-color: #fff;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    .top {
      height: 39px;
      line-height: 39px;
      background-color: #2d2d2d;
      padding: 0 18px 0 18px;
      font-size: 14px;
      font-family: Arial, Helvetica, sans-serif;
      color: #fff;
      i {
        float: right;
        color: #666;
        font-size: 18px;
        cursor: pointer;
      }
    }
    .login-form {
      padding: 30px 0 43px 0;
      margin: 0 154px 0 154px;
      width: 200px;
      height: 152px;
      display: flex;
      flex-direction: column;
      input {
        height: 30px;
        box-sizing: border-box;
        padding: 0 8px;
        background-color: rgb(232, 240, 254);
      }
      .pwd {
        margin-top: 10px;
      }
      .country {
        width: 45px;
        height: 30px;
      }
      .msg {
        height: 16.5px;
        vertical-align: top;
        margin-bottom: 15px;
        margin-top: 10px;
        .doLogin {
          display: inline-box;
          width: 67px;

          float: right;
        }
      }
    }
  }
}
</style>
